home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / PANESPLI.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  7KB  |  200 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.14  $
  6. //
  7. // Definition of Pane Splitter classes
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_PANESPLI_H)
  10. #define OWL_PANESPLI_H
  11.  
  12. #if !defined(OWL_SPLITTER_H)
  13. # include <owl/splitter.h>
  14. #endif
  15. #if !defined(OWL_PANESPLI_RH)
  16. # include <owl/panespli.rh>
  17. #endif
  18. #if !defined(CLASSLIB_LISTIMP_H)
  19. # include <classlib/listimp.h>
  20. #endif
  21. #if !defined(CLASSLIB_ALLOCTR_H)
  22. # include <classlib/alloctr.h>
  23. #endif
  24. #if !defined(CLASSLIB_MEMMGR_H)
  25. # include <classlib/memmgr.h>
  26. #endif
  27.  
  28. //
  29. // Define macro [missing from 16-bit headers]used by PANESPLI.CPP
  30. //
  31. #if !defined(IDC_SIZEALL)
  32. # define IDC_SIZEALL         MAKEINTRESOURCE(32646)
  33. #endif
  34.  
  35. #if defined(BI_NAMESPACE)
  36. namespace OWL {
  37. #endif
  38.  
  39. // Generic definitions/compiler options (eg. alignment) preceeding the
  40. // definition of classes
  41. #include <services/preclass.h>
  42.  
  43. //
  44. // ObjectWindows provides explicitly instantiation of these templates [see
  45. // TMPLINST.CPP]. Provide an '__import' version so that modules using the OWL
  46. // DLL rely on the code generated within ObjectWindows.
  47. //
  48. #if defined(BI_COMP_BORLANDC)
  49. # if defined(_OWLDLL) && !defined(_BUILDOWLDLL)
  50.     template class _OWLCLASS TMListElement<TVoidPointer, TStandardAllocator>;
  51.     template class _OWLCLASS TMListBlockInitializer<TVoidPointer, TStandardAllocator>;
  52.     template class _OWLCLASS TMListImp<TVoidPointer, TStandardAllocator>;
  53. # endif
  54. #endif
  55.  
  56. //
  57. // class TPaneSplitter
  58. // ~~~~~ ~~~~~~~~~~~~~
  59. // TPaneSplitter is a class that acts as a container for child windows (called
  60. // panes) and splitters (pane mover, separator).  Supports operatations for
  61. // manipulating panes (add, remove, move, resize, etc) and splitters (drawing,
  62. // width, etc).  Splitters can be moved (thus resizing the panes) by function
  63. // call or mouse input.  Using the mouse, multiple splitters could be moved
  64. // at once. The splitter width indicates the width of the separators and the 
  65. // splitter cushion is the minimum distance btwn separators (to prevent 
  66. // accidental closure of panes).
  67. //
  68. class _OWLCLASS TPaneSplitter : public TLayoutWindow
  69. {
  70.   public:
  71.     typedef TShouldDelete::TDelete TDelete;
  72.  
  73.     TPaneSplitter(TWindow*        parent,
  74.                   const char far* title = 0,
  75.                   int             splitterWidth = 0,
  76.                   TModule*        module = 0);
  77.    ~TPaneSplitter();
  78.  
  79.     // Pane functions
  80.     //
  81.     bool          SplitPane(TWindow* target, TWindow* newPane,
  82.                             TSplitDirection splitDir, float percent = .50);
  83.     bool          RemovePane(TWindow* pane, TDelete dt = TShouldDelete::DefDelete);
  84.     bool          ReplacePane(TWindow* target, TWindow* newPane,
  85.                               TDelete dt = TShouldDelete::DefDelete);
  86.     bool          SwapPanes(TWindow* pane1, TWindow* pane2);
  87.     int           PaneCount();
  88.     void          RemoveAllPanes(TDelete dt = TShouldDelete::DefDelete);
  89.  
  90.     typedef int (*TForEachPaneCallback)(TWindow&, void*);
  91.     void          ForEachPane(TForEachPaneCallback callback, void* p);
  92.  
  93.     // Splitter functions
  94.     //
  95.     int           GetSplitterWidth();
  96.     int           SetSplitterWidth(int newWidth);
  97.     void          SetSplitterCushion(uint cushion);
  98.     bool          MoveSplitter(TWindow* pane, int dist);
  99.  
  100.     bool          DelObj(TDelete dt);
  101.  
  102.   protected:
  103.     void          SetupWindow();
  104.     void          CleanupWindow();
  105.     void          EvSize(uint sizeType, TSize& size);
  106.     virtual void  DrawSplitter(TDC& dc, const TRect& splitter);
  107.  
  108.   private:
  109.     enum    TTraversalOrder {psPreOrder, psInOrder, psPostOrder};
  110.     typedef int (TPaneSplitter::*TForEachObjectCallback)(TWindow*, void*, void*);
  111.  
  112.     TSplitterIndicatorList SplitterIndicatorList;
  113.     TSplitterIndicatorMgr  SplitterIndicatorMgr;
  114.     int                    SplitterWidth;
  115.     uint                   SplitterCushion;
  116.     bool                   Dragging;
  117.     HCURSOR                ResizeCursorH;
  118.     HCURSOR                ResizeCursorV;
  119.     HCURSOR                ResizeCursorHV;
  120.     bool                   PaneSplitterResizing;
  121.     TDelete                ShouldDelete;
  122.  
  123.     void          MouseMoved(const TPoint& point);
  124.     void          StartSplitterMove(TSplitter* splitter, const TPoint& point);
  125.     void          EndSplitterMove();
  126.     void          SetSplitterMoveCursor(TSplitter* splitter, const TPoint& point);
  127.  
  128.     void          ForEachObject(TWindow* o,
  129.                                 TForEachObjectCallback callback,
  130.                                 void* p1, void* p2 = 0,
  131.                                 TTraversalOrder order = psPostOrder);
  132.     void          GetDefLM(TLayoutMetrics& lm);
  133.     void          ScreenToClientRect(TRect& rect);
  134.     void          ClientToScreenRect(TRect& rect);
  135.     bool          HasPane(TWindow* p);
  136.     TLayoutWindow* DoRemovePane(TWindow* pane, TDelete dt = TShouldDelete::DefDelete);
  137.     void          FindIntersectingSplitters(const TPoint& point);
  138.     virtual int   RemovePanes();
  139.     void          MoveSplitters();
  140.     void          DestroyPane(TWindow* pane, TDelete dt = TShouldDelete::DefDelete);
  141.  
  142.     // ForEachObject() callbacks..
  143.     //
  144.     int           DoForEachPane(TWindow* splitter, void* p1, void* p2);
  145.     int           DoFindIntersectingSplitters(TWindow* splitter, void* p1, void* p2);
  146.     int           GetListOfPanesToRemove(TWindow* splitter, void* p1, void* p2);
  147.     int           AdjSplitterWidth(TWindow* splitter, void* p1, void* p2);
  148.     int           DoPaneCount(TWindow* splitter, void* p1, void* p2);
  149.     int           GetPanes(TWindow* splitter, void* p1, void* p2);
  150.     int           GetSplitters(TWindow* splitter, void* p1, void* p2);
  151.  
  152.   friend class _OWLCLASS TSplitter;
  153.   friend class _OWLCLASS THSplitter;
  154.   friend class _OWLCLASS TVSplitter;
  155.  
  156.   DECLARE_RESPONSE_TABLE(TPaneSplitter);
  157. };
  158.  
  159. // Generic definitions/compiler options (eg. alignment) following the
  160. // definition of classes
  161. #include <services/posclass.h>
  162.  
  163. #if defined(BI_NAMESPACE)
  164. } // namespace OWL
  165. #endif
  166.  
  167. //----------------------------------------------------------------------------
  168. // Inline implementations
  169. //
  170.  
  171. //
  172. // Return the width of the splitter widget.
  173. //
  174. inline int
  175. TPaneSplitter::GetSplitterWidth()
  176. {
  177.   return SplitterWidth;
  178. }
  179.  
  180. //
  181. // Set the cushion for the splitter widget.
  182. //
  183. inline void
  184. TPaneSplitter::SetSplitterCushion(uint cushion)
  185. {
  186.   SplitterCushion = cushion;
  187. }
  188.  
  189. //
  190. // Return true if the object should be deleted.
  191. //
  192. inline bool
  193. TPaneSplitter::DelObj(TDelete dt)
  194. {
  195.   return dt == TShouldDelete::Delete ||
  196.          (dt==TShouldDelete::DefDelete && ShouldDelete==TShouldDelete::Delete);
  197. }
  198.  
  199. #endif // OWL_PANESPLI_H
  200.